//
//  MainPageModuleApi.m
//  QinghaiTourism
//
//  Created by QianXiaoShu on 16/4/4.
//  Copyright © 2016年 QianXiaoShu. All rights reserved.
//

#import "MainPageModuleApi.h"

@implementation MainPageModuleApi
//更改司机接单状态
+(void)driverChangeGetOrderStateWithDriverId:(NSString *)driverId completion:(AICompletionBlock)block{
   
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/homepage/changeDriverOrderState&drvierId=%@",driverId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_changeDriverOrderState params:dic completion:block];

}

//首页数据展示
+ (void)showMainPageWithdrvierId:(NSString *)drvierId completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/homepage/getDriverMainInfo&driverId=%@",drvierId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getDriverMainInfo params:dic completion:block];
}



//获取消息中心--消息详情
/*
 messId 消息ID
 
 */
+ (void)getMessDetailsWithMessId:(NSString *)messId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/message/getMessDetails&messId=%@",messId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getMessDetails params:dic completion:block];

}


//删除消息
+ (void)deleteMessWithMessId:(NSString *)messId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverMessage/deleteMess&messId=%@",messId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_deleteMess params:dic completion:block];

}




//获取消息数据
+ (void)getDriverMessageListWithDriverId:(NSString *)driverId pageIndex:(NSString *)pageIndex pageSize:(NSString *)pageSize  completion:(AICompletionBlock)block{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverMessage/getDriverMessageList&driverId=%@&pageIndex=%@&pageSize=%@",driverId,pageIndex,pageSize];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getDriverMessageList params:dic completion:block];

}

//司机确认接单
+ (void)driverConfirmOrdersWithOrderId:(NSString *)orderId driverId:(NSString *)driverId completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/driverConfirmOrders&orderId=%@&driverId=%@",orderId,driverId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_driverConfirmOrders params:dic completion:block];

}

//订单信息
+ (void)pullOrderInfoWithOrderId:(NSString *)orderId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/pullOrderInfo&orderId=%@",orderId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_pullOrderInfo params:dic completion:block];

}
//删除订单
+(void)removeOrderWithOrderId:(NSString *)orderId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/removeOrder&orderId=%@",orderId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getAllEavList params:dic completion:block];

}

//完成出游
+ (void)completeTravelWithOrderId:(NSString *)orderId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/completeTravel&orderId=%@",orderId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_completeTravel params:dic completion:block];

}


//获取订单详情
+ (void)getOrderDetailsWithOrderId:(NSString *)orderId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/getOrderDetails&orderId=%@",orderId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getOrderDetails params:dic completion:block];

}


/*
 司机订单列表
 completeState:状态  0：待完成   1已完成
 pageIndex:页码
 pageSize:页大小
 */
+ (void)driverOrderListWithDriverID:(NSString *)driverId completeState:(NSString *)completeState pageIndex:(NSString *)pageIndex pageSize:(NSString *)pageSize completion:(AICompletionBlock)block{NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/driverOrderList&driverId=%@&completeState=%@&pageIndex=%@&pageSize=%@",driverId,completeState,pageIndex,pageSize];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_driverOrderList params:dic completion:block];

}






/**
 
 获取线路详情
 
 **/



+ (void)getTourisDetailsWithTourisId:(NSString *)tourisId completion:(AICompletionBlock)block{NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/touristroutes/getTourisDetails&tourisId=%@",tourisId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getTourisDetails params:dic completion:block];

}
//线路评价
+ (void)getTourisEvaluateWithTourisId:(NSString *)tourisId pageIndex:(NSString *)pageIndex pageSize:(NSString *)pageSize completion:(AICompletionBlock)block{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/touristroutes/getTourisEvaluate&tourisId=%@&pageIndex=%@&pageSize=%@",tourisId,pageIndex,pageSize];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getTourisEvaluate params:dic completion:block];
    
}


//获取服务介绍
+ (void)getServiceIntroductionWithtraveld:(NSString *)traveld completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/touristroutes/getServiceIntroduction&routeId=%@",traveld];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getServiceIntroduction params:dic completion:block];

}

//获取游客列表
+ (void)getOrdertouristListWithOrderId:(NSString *)orderId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverOrderBusiness/getOrdertouristList&orderId=%@",orderId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getOrdertouristList params:dic completion:block];

}


/*
 //获取财务数据
 startUpdDate:开始时间
 endUpdDate：结束时间
 */
+(void)getDriverFinanceInfoWithDriverId:(NSString *)driverId pageIndex:(NSString *)pageIndex pageSize:(NSString *)pageSize startUpdDate:(NSString *)startUpdDate endUpdDate:(NSString *)endUpdDate completion:(AICompletionBlock)block{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverFinance/getDriverFinanceInfo&driverId=%@&pageIndex=%@&pageSize=%@",driverId,pageIndex,pageSize];
    
    if (![QHTools isEmpty:startUpdDate] && [QHTools isEmpty:endUpdDate]) {
       

        unEncode = [NSString stringWithFormat:@"server=app/driverFinance/getDriverFinanceInfo&driverId=%@&pageIndex=%@&pageSize=%@&startUpdDate=%@000",driverId,pageIndex,pageSize,startUpdDate];
        
        
    }
    else
    if (![QHTools isEmpty:endUpdDate] && [QHTools isEmpty:startUpdDate]) {
        
        unEncode = [NSString stringWithFormat:@"server=app/driverFinance/getDriverFinanceInfo&driverId=%@&pageIndex=%@&pageSize=%@&endUpdDate=%@000",driverId,pageIndex,pageSize,endUpdDate];
        
     
        
     }else
    if (![QHTools isEmpty:startUpdDate] && ![QHTools isEmpty:endUpdDate]) {
        unEncode = [NSString stringWithFormat:@"server=app/driverFinance/getDriverFinanceInfo&driverId=%@&pageIndex=%@&pageSize=%@&startUpdDate=%@000&endUpdDate=%@000",driverId,pageIndex,pageSize,startUpdDate,endUpdDate];
 
    }
 
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [MainPageModuleApi startRequest:_getDriverFinanceInfo params:dic completion:block];

}


#pragma mark ---- 发起请求

+ (AIRequest *) startRequest:(NSString *)method params:(NSDictionary *)param completion:(AICompletionBlock)block {
    
    AIRequest *request = [AIRequest startWithRequestToURL:nil
                                                   method:method
                                                jsonParam:param
                                                  encrypt:NO
                                                    block:block];
    request.module = _mainPageModuleName;
    
    return request;
}




@end
